 package server.life;

 import handling.world.WorldBroadcastService;
 import java.awt.Point;
 import java.util.concurrent.atomic.AtomicBoolean;
 import server.maps.MapleMap;
 import tools.MaplePacketCreator;
 import tools.Randomizer;

 public class SpawnPointAreaBoss
   extends Spawns
 {
   private final MapleMonsterStats monster;
   private final Point pos1;
   private final Point pos2;
   private final Point pos3;
   private final int mobTime;
   private final int fh;
   private final int f;
   private final int id;
/*  21 */   private final AtomicBoolean spawned = new AtomicBoolean(false);
   private final String msg;
   private long nextPossibleSpawn;
   private boolean sendWorldMsg = false;

   public SpawnPointAreaBoss(MapleMonster monster, Point pos1, Point pos2, Point pos3, int mobTime, String msg, boolean shouldSpawn, boolean sendWorldMsg) {
/*  27 */     this.monster = monster.getStats();
/*  28 */     this.id = monster.getId();
/*  29 */     this.fh = monster.getFh();
/*  30 */     this.f = monster.getF();
/*  31 */     this.pos1 = pos1;
/*  32 */     this.pos2 = pos2;
/*  33 */     this.pos3 = pos3;
/*  34 */     this.mobTime = (mobTime < 0) ? -1 : (mobTime * 1000);
/*  35 */     this.msg = msg;
/*  36 */     this.sendWorldMsg = (msg != null && sendWorldMsg);
/*  37 */     this.nextPossibleSpawn = System.currentTimeMillis() + (shouldSpawn ? 0L : this.mobTime);
   }


   public int getF() {
/*  42 */     return this.f;
   }


   public int getFh() {
/*  47 */     return this.fh;
   }


   public MapleMonsterStats getMonster() {
/*  52 */     return this.monster;
   }


   public byte getCarnivalTeam() {
/*  57 */     return -1;
   }


   public int getCarnivalId() {
/*  62 */     return -1;
   }


   public boolean shouldSpawn(long time) {
/*  67 */     return (this.mobTime >= 0 && !this.spawned.get() && this.nextPossibleSpawn <= time);
   }


   public Point getPosition() {
/*  72 */     int rand = Randomizer.nextInt(3);
/*  73 */     return (rand == 0) ? this.pos1 : ((rand == 1) ? this.pos2 : this.pos3);
   }


   public MapleMonster spawnMonster(MapleMap map) {
/*  78 */     Point pos = getPosition();
/*  79 */     MapleMonster mob = new MapleMonster(this.id, this.monster);
/*  80 */     mob.setPosition(pos);
/*  81 */     mob.setCy(pos.y);
/*  82 */     mob.setRx0(pos.x - 50);
/*  83 */     mob.setRx1(pos.x + 50);
/*  84 */     mob.setFh(this.fh);
/*  85 */     mob.setF(this.f);
/*  86 */     this.spawned.set(true);
/*  87 */     mob.addListener(() -> {
           this.nextPossibleSpawn = System.currentTimeMillis();

           if (this.mobTime > 0) {
             this.nextPossibleSpawn += this.mobTime;
           }
           this.spawned.set(false);
         });
/*  95 */     map.spawnMonster(mob, -2);



/*  99 */     if (this.msg != null) {
/* 100 */       if (this.sendWorldMsg) {
/* 101 */         WorldBroadcastService.getInstance().broadcastMessage(MaplePacketCreator.spouseMessage(20, "[系统提示] " + this.msg));
       } else {
/* 103 */         map.broadcastMessage(MaplePacketCreator.serverNotice(6, this.msg));
       }
     }
/* 106 */     return mob;
   }


   public int getMobTime() {
/* 111 */     return this.mobTime;
   }
 }


/* Location:              C:\PGX\Server.jar!\server\life\SpawnPointAreaBoss.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */